<template>
  <UserForm @onSubmit="onSubmit" />
</template>

<script>
import { loginAPI } from '@/api/user'
import UserForm from '@/components/UserForm.vue'
import { setToken } from '@/utils/storage'

export default {
  name: 'LoginPage',
  components: { UserForm },
  methods: {
    async onSubmit (values) {
      const res = await loginAPI(values)
      this.$toast('登录成功')
      // 2.
      setToken(res.data.token)
      this.$router.push('/')
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
